package com.learn.service;

import java.io.InputStream;
import java.rmi.server.ExportException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import sun.misc.IOUtils;
import sun.nio.ch.IOUtil;

/**
 * @Author:Mark
 * @Description:
 * @Date: Created on 11:43 2018-11-13
 * @Modify by:
 */



@Service
public class AwareService implements BeanNameAware, ResourceLoaderAware {

  private String beanName;

  private ResourceLoader resourceLoader;

  @Override
  public void setBeanName(String s) {
    this.beanName=s;
  }

  @Override
  public void setResourceLoader(ResourceLoader resourceLoader) {
    this.resourceLoader=resourceLoader;
  }

  public void openResult () throws Exception {
    System.out.println("bean的名称：=="+this.beanName);
    Resource resource = resourceLoader.getResource("classpath:test.txt");

    System.out.println("文本中的内容为："+ resource.getInputStream().toString());
  }
}

